<template>
  <div class="register-container">
    <div class="login-container">
      <div class="login">
        <div class="logo">
          <img src="../assets/logo-temp.png" alt="logo">
        </div>
        <div class="tips">
          <div class="tips-main">
            <h1>注册</h1>
            <div>注册一个您的点子账号</div>
          </div>
        </div>
        <div class="main">
          <form action="">
            <div class="acount">
              <input :class="acountInputClass" v-model="acount" ref="acount" type="text" @focus="acountF"
                     @blur="acountB">
              <div :class="acountClass">账号</div>
            </div>
            <div class="password">
              <input :class="passwordInputClass" v-model="password" ref="password" type="password" @focus="passwordF"
                     @blur="passwordB">
              <div :class="passwordClass">密码</div>
              <div class="confirm-password">
                <input :class="confirmPasswordInputClass" v-model="confirmPassword" ref="password" type="password"
                       @focus="confirmPasswordF"
                       @blur="confirmPasswordB">
                <div :class="confirmPasswordClass">确认密码</div>
              </div>
            </div>
          </form>
          <span :class="checkClass" v-show="check">两次密码输入不相同</span>
        </div>
        <div class="btns">
          <router-link to="/login">
            <div class="register">
              <span>登录已有账号</span>
            </div>
          </router-link>
          <router-link to="/index">
            <div class="login-btn">
              <span>注册</span>
            </div>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Register',
  data () {
    return {
      acountClass: 'place-acount',
      passwordClass: 'place-password',
      acountInputClass: 'acount-input',
      passwordInputClass: 'password-input',
      confirmPasswordClass: 'place-confirm-password',
      confirmPasswordInputClass: 'confirm-password-input',
      checkClass: 'check-fail',
      acount: '',
      password: '',
      confirmPassword: '',
      check: false
    }
  },
  methods: {
    acountF () {
      this.acountClass = 'place-acount-hover'
      this.acountInputClass = 'acount-input-hover'
    },
    acountB () {
      if (this.acount === '') {
        this.acountClass = 'place-acount'
      } else {
        this.acountClass = 'place-acount-hover'
      }
      this.acountInputClass = 'acount-input'
    },
    passwordF () {
      this.passwordClass = 'place-password-hover'
      this.passwordInputClass = 'password-input-hover'
    },
    passwordB () {
      if (this.password === '') {
        this.passwordClass = 'place-password'
      } else {
        this.passwordClass = 'place-password-hover'
      }
      this.passwordInputClass = 'password-input'
    },
    confirmPasswordF () {
      this.confirmPasswordClass = 'place-confirm-password-hover'
      this.confirmPasswordInputClass = 'confirm-password-input-hover'
    },
    confirmPasswordB () {
      if (this.confirmPassword === '') {
        this.confirmPasswordClass = 'place-confirm-password'
      } else {
        this.confirmPasswordClass = 'place-confirm-password-hover'
      }
      this.confirmPasswordInputClass = 'confirm-password-input'
    }
  },
  watch: {
    confirmPassword (val) {
      if (val === this.password) {
        this.check = false
      } else {
        this.check = true
      }
    }
  }
}
</script>

<style scoped>
.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login {
  width: 646px;
  height: 542px;
  padding: 48px 30px 4px;
  box-sizing: border-box;
  border: 1px solid #f6815b;
  border-radius: 10px;
  background-color: #fed71a;
  opacity: .9;
  z-index: 2;
  display: flex;
  flex-direction: column;
  position: relative;
}

.logo {
  height: 89px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.tips {
  height: 80px;
  display: flex;
  justify-content: center;
}

.tips h1 {
  color: #202124;
  padding-bottom: 0;
  padding-top: 16px;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.3333;
  margin-bottom: 0;
  margin-top: 0;
  text-align: center;
}

.main {
  margin-top: 20px;
  position: relative;
  color: #000000;
}

.acount-input {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 336px;
  margin: 1px 1px 10px 1px;
  padding: 13px 15px;
  outline: none;
  border: 1px solid #2c2c2c;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.acount-input-hover {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 336px;
  margin: 1px 1px 10px 1px;
  padding: 13px 15px;
  outline: none;
  border: 2px solid blue;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.password-input {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 145px;
  margin: 1px 7px 10px 7px;
  padding: 13px 15px;
  outline: none;
  border: 1px solid #2c2c2c;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.password-input-hover {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 145px;
  margin: 1px 7px 10px 7px;
  padding: 13px 15px;
  outline: none;
  border: 2px solid blue;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.confirm-password-input {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 145px;
  margin: 1px 7px 10px 7px;
  padding: 13px 15px;
  outline: none;
  border: 1px solid #2c2c2c;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.confirm-password-input-hover {
  border-radius: 4px;
  color: #202124;
  font-size: 17px;
  height: 45px;
  width: 145px;
  margin: 1px 7px 10px 7px;
  padding: 13px 15px;
  outline: none;
  border: 2px solid blue;
  z-index: 2;
  background-color: #fed71a;
  opacity: .5;
}

.acount {
  display: flex;
  justify-content: center;
}

.password {
  display: flex;
  justify-content: center;
}

.confirm-password {
  display: flex;
  justify-content: center;
}

.place-acount {
  font-size: 20px;
  font-weight: 400;
  position: absolute;
  top: 23px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: transparent;
  z-index: 1;
}

.place-acount-hover {
  font-size: 12px;
  font-weight: 400;
  position: absolute;
  top: -7px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: #fed71a;
  z-index: 2;
}

.place-password {
  font-size: 20px;
  font-weight: 400;
  position: absolute;
  top: 107px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: transparent;
  z-index: 1;
}

.place-password-hover {
  font-size: 12px;
  font-weight: 400;
  position: absolute;
  top: 78px;
  left: 125px;
  color: #000;
  transition: all .3s;
  background-color: #fed71a;
  z-index: 2;
}

.place-confirm-password {
  font-size: 20px;
  font-weight: 400;
  position: absolute;
  top: 107px;
  left: 310px;
  color: #000;
  transition: all .3s;
  background-color: transparent;
  z-index: 1;
}

.place-confirm-password-hover {
  font-size: 12px;
  font-weight: 400;
  position: absolute;
  top: 78px;
  left: 310px;
  color: #000;
  transition: all .3s;
  background-color: #fed71a;
  z-index: 2;
}

.btns {
  width: 55%;
  display: flex;
  justify-content: space-between;
  margin-left: 120px;
  margin-top: 30px;
  position: absolute;
  bottom: 60px;
}

.register {
  width: 100px;
  height: 36px;
  cursor: pointer;
  line-height: 36px;
  border-radius: 4px;
  transition: all .3s;
}

.register:hover {
  background-color: #e7ca3a;
}

.register:hover span {
  color: #287ae7;
}

.register:active {
  background-color: #c5ad32;
}

.register:active span {
  color: #236bcb;
}

.register span {
  color: #317fe7;
  display: block;
  align-items: center;
  transition: all .3s;
}

.login-btn {
  width: 90px;
  height: 40px;
  line-height: 40px;
  background-color: #1a73e8;
  border-radius: 4px;
  cursor: pointer;
  transition: all .3s;
}

.login-btn span {
  display: block;
  text-align: center;
  color: #ffffff;
  transition: all .3s;
}

.login-btn:hover {
  background-color: #1969d7;
}

.login-btn:hover span {
  color: #eaeaea;
}

.login-btn:active {
  background-color: #1257b0;
}

.login-btn:active span {
  color: #dcdcdc;
}

.check-fail {
  padding-left: 115px;
  display: block;
  color: #c70000;
}

.check-pass {
  padding-left: 115px;
  display: none;
  color: #c70000;
}
</style>
